package com.demo.afternoon;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @ClassName Set
 * @Description TODO
 * @Author tianqinglong
 * @Date 16:43 2022/7/8
 * @Version 1.0
 **/
public class Set {
    public static void main(String[] args) {
        HashSet遍历();

    }

    private static void HashSet遍历() {
        HashSet<String> set = new HashSet<>();
        set.add("Aaaa");
        set.add("Aaaa");
        set.add("BBBB");
        for (String s : set) {
            System.out.println(s+" ");
        }
        System.out.println();
        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        System.out.println();
        set.stream().forEach(System.out::println);
    }

}
